package com.trsvax.gwthello.client.gwtui.widgets;

import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.StackPanel;

public class StackPanelWidget extends Composite {
	public StackPanelWidget(String id, Dictionary dictionary) {
		Element element = RootPanel.get(id).getElement();

		NodeList<Element> nl = element.getElementsByTagName("dt");

		StackPanel tp = new StackPanel();
		for (int i = 0; i < nl.getLength(); i++) {
			Element e = nl.getItem(i).getNextSiblingElement();
			String html = e.getInnerHTML();
			tp.add(new HTML(html), nl.getItem(i).getInnerText());
		}

		// Show the 'bar' tab initially.
		// tp.selectTab(0);
		element.setInnerHTML("");
		initWidget(tp);
	}

}
